function switchItem(str,total,t){
	for(var i=1; i<=total; i++) {
		if(i==t) {
			document.getElementById(str+"_L_"+i).style.display="none";
			document.getElementById(str+"_S_"+i).style.display="";
		} else {
			document.getElementById(str+"_L_"+i).style.display="";
			document.getElementById(str+"_S_"+i).style.display="none";
		}
	}
}

var Parallaxe = function(id) {
	this.CurrentSlide = 0;
	this.autoSlide = false;
	this.autoSlideInterval = 1;
	
	this.Element = $(id);
	this.Selector = this.Element.down('.prlx-selector');
	this.Foreground = this.Element.down('.prlx-foreground');
	this.Background = this.Element.down('.prlx-background');
	
	this.slide = function() {
		var cards = this.Foreground.childElements();
		if(this.CurrentSlide >= cards.length) {
			this.CurrentSlide = 0;
		}
		if(this.CurrentSlide < 0) {
			this.CurrentSlide = cards.length - 1;
		}
	
		if(this.CurrentSlide != this.OldSlide) {
			if(this.fEffect != null) {
				this.fEffect.cancel();
			}
			if(this.bEffect != null) {
				this.bEffect.cancel();
			}
	
			this.OldSlide = this.CurrentSlide;
	
			var obj = this;
	
			var opt = { x : 0, y : 0, transition : Effect.Transitions.sinoidal, mode : 'absolute' };
	
			opt.x = -1 * this.Foreground.firstDescendant().getWidth() * this.CurrentSlide;
			opt.afterFinish = function() { obj.fEffect = null; };
	
			this.fEffect = new Effect.Move(this.Foreground, opt);

			opt.x = -1 * this.Background.firstDescendant().getWidth() * this.CurrentSlide;
			opt.afterFinish = function() { obj.bEffect = null; };
	
			this.bEffect = new Effect.Move(this.Background, opt);
	
			this.updateSelector();
			this.createInterval();
		}
	};
	
	this.updateSelector = function() {
		this.Selector.childElements().each(function(el, index) {
			if (index != this.CurrentSlide) {
				el.removeClassName('prlx-sel-item-selected');
			} else {
				el.addClassName('prlx-sel-item-selected');
			}
		}, this);
	};
	
	this.goNext = function(e) {
		this.CurrentSlide++;
		this.slide();
	};
	
	this.goPrevious = function(e) {
		this.CurrentSlide--;
		this.slide();
	};
	
	this.goSelector = function(e) {
		var el = e.findElement('li');
		this.CurrentSlide = el.Index;
		this.slide();
	};
	
	this.createInterval = function() {
		clearInterval(this.autoSlideInterval);
		var obj = this;
		this.autoSlideInterval = setInterval(function() {
			if (obj.autoSlide) { obj.goNext(); }
		}, this.autoSlideInterval * 1000);
	};
	
	this.Element.observe('mouseover', (function() { this.autoSlide = false; }).bind(this));
	this.Element.observe('mouseout', (function() { this.autoSlide = true; }).bind(this));
	this.Selector.childElements().each(function(el, index) { el.Index = index; });
	this.Selector.observe('click', this.goSelector.bind(this));
	this.slide(this.CurrentSlide);
};

Event.observe(window, 'load', function() {
	new Parallaxe('prlx');
});

//收藏本站
function AddFavorite(sURL, sTitle) {
	sURL = encodeURI(sURL);
	try {
		window.external.addFavorite(sURL, sTitle);
	} catch (e) {
		try {
			window.sidebar.addPanel(sTitle, sURL, "");
		} catch (e) {
			alert("加入收藏失败，请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
		}
	}
}

//设为首页
function SetHome(url) {
	if (document.all) {
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage(url);
	} else {
		alert("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");
	}
}

//搜索功能
function search_2() {
	var searchform = window.document.getElementById("scan");
	searchform.submit();
}

//搜索功能
function search() {
	var searchform = window.document.getElementById("searchform");
	searchform.submit();
}


